﻿using System;
/*Sorting an array means to arrange its elements in increasing order. Write a program to sort an array
 * Use the "selection sort" algorithm: Find the smallest element, move it at the first position, 
 * find the smallest from the rest, move it at the second position, etc.
*/
    class SelectionSort
    {
        static void Main()
        {
            int[] array = { 1, 2, 3, 7, 5, 4 };
            
            int minNumber = 0;
            

            for (int i = 0; i < array.Length - 1; i++)
            {
                minNumber = i;
                for (int j = i + 1; j < array.Length; j++)
                {

                    if (array[j] < array[i])
                    {
                        minNumber = j;
                        
                    }                    
                }

                if (minNumber != i)
                {
                    int temp = array[i];
                    array[i] = array[minNumber];
                    array[minNumber] = temp;
                }
            }

            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine(array[i]);
            }
        }
    }

